# -*- coding: utf-8 -*-

import numpy
import cv2
from splitIMG import *

file_dir = '../../process'
class_type = 'plane'

root, patches = getPatches(file_dir)
for patch in patches:
    labels = loadLabels(root['label'] + patch + '.txt', class_type)
    if not labels: continue
    image = cv2.imread(root['image'] + patch + '.png')
    
    cv2.imshow('origin', image)
    for label in labels:
        bounding_box = numpy.array([[ (label[0], label[1]),
                                        (label[2], label[3]), 
                                        (label[4], label[5]), 
                                        (label[6], label[7]) ]])
        cv2.fillPoly(image, bounding_box, (0, 0, 0, 0.5))
    cv2.imshow('plane', image)
    if cv2.waitKey(0) == ord('q'): break